package com.java1412.controller;

import com.java1412.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author java1412
 * @create 2022-09-14 14:08
 */
@RestController
@Slf4j
public class OrderNacosController {
    // 服务提供者大的地址
//    private static final String PAYMENT_URL = "http://nacos-payment-provider";
//
//    @Autowired
//    private RestTemplate restTemplate;
//
//    @RequestMapping("/consumer/payment/nacos/{id}")
//    public Object getPayment(@PathVariable("id") Integer id) {
//        log.info("********查询的id：" + id);
//        return restTemplate.getForObject(PAYMENT_URL + "/payment/nacos/" + id, String.class);
//    }

    // 注入PaymentFeignService
    @Autowired
    private PaymentFeignService paymentFeignService;

    @RequestMapping("/consumer/payment/feign/nacos/{id}")
    public String paymentInfo2(@PathVariable("id") Integer id) {
        return paymentFeignService.getPayment(id);
    }
}
